//
// Created by shenbin on 2022/5/29.
// https://leetcode.cn/problems/find-minimum-in-rotated-sorted-array/
//

#ifndef ALGORITHM_TRAINNING_C02_LC153_H
#define ALGORITHM_TRAINNING_C02_LC153_H

#include <vector>

using namespace std;

/**
 * 肯定有解的情况
 */
class LeetCode153 {
public:
    int findMin(vector<int> &nums) {
        int left = 0, right = nums.size() - 1;
        while (left < right) {
            mid = (left + right) / 2;
            if (nums[mid] <= nums[right])
                right = mid;
            else
                left = mid + 1;
        }
        return nums[right];
    }
};

#endif //ALGORITHM_TRAINNING_C02_LC153_H
